#include "stm8s_clk.h"
extern CONST uint8_t HSIDivFactor[4];
extern CONST uint8_t CLKPrescTable[8];

/**
 * @brief  System clock initialization using HSI as clock source, configured to 16MHz
 * @note   HSI default calibration is 16MHz, no external components required for system operation
 * @param  None
 * @retval None
 */
void clk_config_init(void)
{
    // Reset clock controller to default state
     CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);  //配置内部高速振荡器（HSI）的分频器--1分频
    __enable_interrupt();//中断使能
    
    	CLK_HSICmd(ENABLE);//内部高频RC开  

   CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER2, ENABLE);  // Timer1
  CLK_PeripheralClockConfig(CLK_PERIPHERAL_UART1, ENABLE); // UART1
  CLK_PeripheralClockConfig(CLK_PERIPHERAL_SPI, ENABLE);   // SPI
   CLK_PeripheralClockConfig(CLK_PERIPHERAL_I2C, ENABLE);   // I2C
      CLK_PeripheralClockConfig(CLK_PERIPHERAL_ADC, ENABLE);   // I2C
   rim();//打开总中断

}

